package prist;

import java.util.Map;

public class Main {
    public static void main(String[] args) {
        Resource_Managenment resource_managenment = new Resource_Managenment();
        Threads[] thread = new Threads[3];
        for (int i = 0; i < 3; i++) {
            //初始化线程
            thread[i].Init_Threads();
            int key = Allocating_Resource(resource_managenment, thread[i]);
            if (key == 1) {

            }

        }

        System.out.println("Hello World!");
    }

    public static int Allocating_Resource(Resource_Managenment resource_managenment, Threads threads) {
        int condation = 0;
        /*第一种就是线程所需要的资源os 立马可以提供直接运行
         *第二种情况时线程所需要的资源os 能够提供，当前不够;等待就好；
         *第三种就是线程所需要的资源os 不能提供，然后直接线程死掉,提醒客户
         * */
        for (Map.Entry<Object, Integer> entry : threads.getThread().entrySet()) {
            Object key = entry.getKey();
            Integer value = entry.getValue();
            if (resource_managenment.getLive_resource().get(key) >= value) {
                condation = 1;
            } else if (resource_managenment.getResource().get(key) >= value) {
                condation = 2;
                break;
            } else if (resource_managenment.getResource().get(key) < value) {
                condation = 3;
                break;
            }
        }
        return condation;
    }

}
